package com.derbysoft.lowcostadapter.web.action.admin.transactionlog;

/**
 * Created by: jason
 * Date: 2012-10-18
 */
public class AvailRequestCounter {

    private static final int ONE_HUNDRED = 100;
    public static final String FORMAT = "%.4f";

    private long totalCount;
    private long realCheckCount;
    private long noAllotmentCount;
    private long queryCacheCount;
    private long maxOccRestrictedCount;
    private long rateHitCount;
    private long roomStayFilteredCount;

    public long getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(long totalCount) {
        this.totalCount = totalCount;
    }

    public long getRealCheckCount() {
        return realCheckCount;
    }

    public void setRealCheckCount(long realCheckCount) {
        this.realCheckCount = realCheckCount;
    }

    public long getNoAllotmentCount() {
        return noAllotmentCount;
    }

    public void setNoAllotmentCount(long noAllotmentCount) {
        this.noAllotmentCount = noAllotmentCount;
    }

    public long getQueryCacheCount() {
        return queryCacheCount;
    }

    public void setQueryCacheCount(long queryCacheCount) {
        this.queryCacheCount = queryCacheCount;
    }

    public long getMaxOccRestrictedCount() {
        return maxOccRestrictedCount;
    }

    public void setMaxOccRestrictedCount(long maxOccRestrictedCount) {
        this.maxOccRestrictedCount = maxOccRestrictedCount;
    }

    public long getRateHitCount() {
        return rateHitCount;
    }

    public void setRateHitCount(long rateHitCount) {
        this.rateHitCount = rateHitCount;
    }

    public long getRoomStayFilteredCount() {
        return roomStayFilteredCount;
    }

    public void setRoomStayFilteredCount(long roomStayFilteredCount) {
        this.roomStayFilteredCount = roomStayFilteredCount;
    }

    public String getRealCheck() {
        if (totalCount == 0) {
            return "0";
        }
        return String.format(FORMAT, (double) realCheckCount / totalCount * ONE_HUNDRED) + "%";
    }

    public String getFromCache() {
        if (totalCount == 0) {
            return "0";
        }
        return String.format(FORMAT, (double) queryCacheCount / totalCount * ONE_HUNDRED) + "%";
    }

    public String getMaxOccRestricted() {
        if (queryCacheCount == 0) {
            return "0";
        }
        return String.format(FORMAT, (double) maxOccRestrictedCount / queryCacheCount * ONE_HUNDRED) + "%";
    }

    public String getRateHit() {
        if (queryCacheCount == 0) {
            return "0";
        }
        return String.format(FORMAT, (double) rateHitCount / queryCacheCount * ONE_HUNDRED) + "%";
    }

    public String getRoomStayFiltered() {
        if (queryCacheCount == 0) {
            return "0";
        }
        return String.format(FORMAT, (double) roomStayFilteredCount / queryCacheCount * ONE_HUNDRED) + "%";
    }
}
